package com.cstp.entity;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.cstp.web.req.QuestionReq;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.List;

/**
 * @author watts
 */
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("t_question")
public class Question extends OptEntity implements Serializable {

    @TableId(type = IdType.AUTO)
    private Long id;

    private String title;

    private Integer type;

    public static Question of(QuestionReq req) {
        Question question = new Question();
        BeanUtils.copyProperties(req, question);
        return question;
    }

    @TableField(exist = false)
    @Schema(description = "问题选项")
    private List<QuestionOption> options;
}
